<?php
function equal($unitCompare, $newData)
{
	for ($i=0; $i<count($unitCompare); $i++)
	{
		if ($unitCompare[$i]!=$newData[count($newData)-count($unitCompare)+$i])
			return false;
	}
	return true;
}
$unit = 4;
$data = array("<td width=\"100\"><img src=\"./images/normal.gif\" border=\"0\" width=\"100\" height=\"100\" /></td>", 
			  "<td width=\"100\"><img src=\"./images/gold.gif\" border=\"0\" width=\"100\" height=\"100\" /></td>", 
			  "<td width=\"100\"><img src=\"./images/platium.gif\" border=\"0\" width=\"100\" height=\"100\" /></td>", 
			  "<td width=\"100\"><img src=\"./images/dinamond.gif\" border=\"0\" width=\"100\" height=\"100\" /></td>", 
			  "<td width=\"100\"><img src=\"./images/hot.gif\" border=\"0\" width=\"100\" height=\"100\" /></td>");
$unitCompare = $newData = array();
for ($i=0; $i<count($data); $i++) 
{
	if ($i<$unit) $unitCompare[] = $data[$i];
	$newData[] = $data[$i];
}
echo $unit;
echo "<pre>";
print_r($newData);
echo "</pre>";
$nextData = 0;
$i=0;
while (true)
{
	if ($nextData>=count($data)) $nextData = 0;
	$newData[] = $data[$nextData];	
	if ((count($newData))%$unit == 0 && equal($unitCompare, $newData)) break;
	$nextData++;
	
	$i++;
}
echo "<pre>";
print_r($newData);
echo "</pre>";
?>